#include <functional>
#include <iostream>
#include <set>

using namespace std;

class Student{
public:
	char *name;
	int age;
public:
	Student(char *name, int age)
	{
		this->name = name;
		this->age = age;
	}
	char * getName()
	{
		return this->name;
	}
	int getAge()
	{
		return this->age;
	}
};

// 函数对象，仿函数
struct compare{
	// 重载括号运算符
	bool operator () (const Student& _Left, const Student& _Right)
	{
		return _Left.age > _Right.age;
	}
	
};

int main()
{

	set<Student,compare> st;

	Student stu1((char *)"tom",12);
	Student stu2((char *)"jack",13);
	Student stu3((char *)"amin",15);

	st.insert(stu1);
	st.insert(stu2);
	st.insert(stu3);


	for (set<Student>::iterator it = st.begin(); it != st.end(); it++) {
		cout << "name: " << it->name << "age:" << it->age << endl;	
	}

	return 0;
}
